package com.gxa.guahao01.service;

import com.gxa.guahao01.pojo.HuanZheJiuZhenKa;
import com.gxa.guahao01.mapper.HuanZheJiuZhenKaMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 患者就诊卡(HuanZheJiuZhenKa)表服务实现类
 *
 * @author xyc
 * @since 2021-03-16 16:52:16
 * @version 1.0
 */
@Service("huanZheJiuZhenKaService")
public class HuanZheJiuZhenKaServiceImpl {
    @Resource
    private HuanZheJiuZhenKaMapper huanZheJiuZhenKaMapper;

    /**
     * 查询所有数据
     * @return  返回所有数据
     */
    public Map<String, Object> chaXunAll() {
        Map<String, Object> map = new HashMap<>();
        // 前端端分离时，前端人员会首先判断code值是否满足200，如果不是200，则提醒用户失败
        map.put("code", 200);
        map.put("msg", "查询成功");
        map.put("list", this.huanZheJiuZhenKaMapper.chaXunAll());
        return map;
    }



    /**
     * 新增数据
     *
     * @param huanZheJiuZhenKa 实例对象
     * @return 实例对象
     */
    public Map<String, Object> xinZeng(HuanZheJiuZhenKa huanZheJiuZhenKa) {
        // UUID.randomUUID()  返回内容：asd21321-ewrewrew213213-123213zsad-123asdasd这样的形态
        this.huanZheJiuZhenKaMapper.xinZeng(huanZheJiuZhenKa);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);   // 前端端分离时，前端人员会首先判断code值是否满足200，如果不是200，则提醒用户失败
        map.put("msg", "新增成功");
        return map;
    }

    /**
     * 通过ID更新单条数据
     *
     * @param huanZheJiuZhenKa 实例对象
     * @return 实例对象
     */
    public Map<String, Object> gengXinById(HuanZheJiuZhenKa huanZheJiuZhenKa) {
        this.huanZheJiuZhenKaMapper.gengXinById(huanZheJiuZhenKa);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);   // 前端端分离时，前端人员会首先判断code值是否满足200，如果不是200，则提醒用户失败
        map.put("msg", "更新成功");
        return map;
    }
    /**
     * 通过卡号或者身份证号查询单条数据
     *
     * @param huanZheKaHao 实例对象
     * @return 实例对象
     */
    public Map<String, Object> chaXunByKaHao(String huanZheKaHao, String shenFenZheng, String xingMing, String shouJiHao, String kaiShiShiJian, String jieShuShiJian) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);   // 前端端分离时，前端人员会首先判断code值是否满足200，如果不是200，则提醒用户失败
        map.put("msg", "查询成功");
        map.put("list", this.huanZheJiuZhenKaMapper.chaXunByKaHao(huanZheKaHao,shenFenZheng,xingMing,shouJiHao,kaiShiShiJian,jieShuShiJian));
        return map;
    }

}